const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            tabledata: [],
            Task_SerialNumber: "",
            // page: {
            //     PageNumber: 1, //页码
            //     RowAmount: 10,
            //     Condition: "",
            // },
            currentTableData: [], // 当前页显示的数据
            currentPage: 1, // 当前页码
            pageSize: 10 // 每页显示条目数
        };
    },
    mounted() {

        let ls_URL = window.location.href;
        this.Task_SerialNumber = getQueryObject(ls_URL, "nodeKey");

        this.GetTaskInfoAndSetPlanInfo();
      



    },
    methods: {
        handleSizeChange(val) {
            this.pageSize = val;
            this.updateCurrentTableData();
        },
        handleCurrentChange(val) {
            this.currentPage = val;
            this.updateCurrentTableData();
        },
        updateCurrentTableData() {
            const start = (this.currentPage - 1) * this.pageSize;
            const end = start + this.pageSize;
            this.currentTableData = this.tabledata.slice(start, end);
        },
        GetTaskInfoAndSetPlanInfo() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                type: "post",
                data: {
                    SQLSerialNumber: "SQL_GetTaskInfo",
                    Condition: "",
                    ExtensionCondition: window.btoa(
                        unescape(
                            encodeURIComponent(
                                " where patrol_task.Row_Status='0' and  patrol_task.Task_SerialNumber='" + this.Task_SerialNumber + "'"
                            ))),
                },
                success: (TaskInfo) => {

                    this.generateDateRange(TaskInfo);

                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            })
        },


        generateDateRange(TaskInfo) {
            const startDate = new Date(TaskInfo[0].Start_Date);
            const endDate = new Date(TaskInfo[0].End_Date);
            const Task_SerialNumber = TaskInfo[0].Task_SerialNumber;
            const Task_Area = TaskInfo[0].Task_Area;
            const team_SerialNumber = TaskInfo[0].team_SerialNumber;
            const team_name = TaskInfo[0].team_name;
            const Contact_Phone = TaskInfo[0].Contact_Phone;


            let _tabledata = [];
            let _this = this;

            for (let date = startDate; date <= endDate; date.setDate(date.getDate() + 1)) {


                let Objdate = new Object;
                Objdate.PlanDate = date.toISOString().split('T')[0];
                Objdate.Task_SerialNumber = Task_SerialNumber;
                Objdate.Task_Area = Task_Area;
                Objdate.team_SerialNumber = team_SerialNumber;
                Objdate.team_name = team_name;
                Objdate.Contact_Phone = Contact_Phone;
                _tabledata.push(Objdate);
            }
            _this.tabledata = _tabledata;

            this.updateCurrentTableData();
            console.log(_this.tabledata);
        },

        // handleSizeChange(val) {
        //     this.page.RowAmount = val;
        //     this.page.PageNumber = 1; // 重置为第一页
        // },
        // handleCurrentChange(val) {
        //     this.page.PageNumber = val;
        // },

    },

};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-select', ylSelect);
app.component('yl-text-editor', ylTextEditor);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
